﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataSet QueryVAKDBEZ(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM VAKDBEZ WHERE  ROWNUM<2 ";
                    break;
                case 3:
                    or1.CommandText = "  SELECT A.* FROM VAKDBEZ  A "
                    + " JOIN VKPOS ON VKPKOLL=VAKBKOLL AND VKPART=VAKBART AND VKPFARBE=VAKBFARBE AND VKPKUNDNR=VAKBKUNDNR"
                        + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD ";
                    or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                    or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                    or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "VAKDBEZ";
            Return = Result;
            return Return;
        }

    }
}
